-
-
Notifications
You must be signed in to change notification settings - Fork 303
Fix namespaced models foreign key #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
crmne
merged 14 commits into
crmne:main
from
andreaslillebo:fix/namespaced-models-foreign-key
Nov 5, 2025
Merged
Fix namespaced models foreign key #460
crmne
merged 14 commits into
crmne:main
from
andreaslillebo:fix/namespaced-models-foreign-key
Nov 5, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Would be happy to support getting this PR over the line, this is currently blocking our upgrade to the newest version @andreaslillebo @crmne |
1240926 to
6661392
Compare
crmne
approved these changes
Nov 5, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #460 +/- ##
=======================================
Coverage 89.24% 89.24%
=======================================
Files 37 37
Lines 1925 1925
Branches 541 541
=======================================
Hits 1718 1718
Misses 207 207 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, thank you very much for all the effort you put into this gem. It is amazing. 🚀
What this does
Version 1.8.2 breaks namespaced models with custom foreign keys. Consider the following example:
It does not work, since the correct foreign key should have been
support_messages.conversation_id.I have added a test showcasing this and implemented a fix.
Since we cannot infer foreign keys automatically when it doesn't match the model-name, we expose options to pass in a foreign key, similarly to associations in Rails:
Generators have also been updated to add foreign keys if needed.
Type of change
Scope check
Quality check
overcommit --installand all hooks passbundle exec rake vcr:record[provider_name]bundle exec rspecmodels.json,aliases.json)API changes
Related issues
Fixes bug introduced in #425